#include <iostream>

void sort(int[], int);

int main()
{
	std::cout << "Enter numbers (-1 to quit):\n";

	int num = 0;
	int numbers[25];
	int n = 0;

	do
	{
		std::cin >> num;

		if(num != -1)
		{
			numbers[n] = num;
			++n;
		}
	}
	while(num != -1);

	int number_of_maximums = 0;
	
	std::cout << "Enter the number of maximums: ";
	do
	{
		std::cin >> number_of_maximums;
	}
	while(number_of_maximums >= n);

	// sorting

	sort(numbers,n);

	// maximums

	int j = 0;	
	int i = 0;
	
	do
	{
		if(numbers[i] > numbers[i+1])
		{
			std::cout << "maximum" << ++j << ": " << numbers[i] << std::endl;
			--number_of_maximums; 
		}

		++i;
	}
	while(number_of_maximums != 0);

	return 0;
}

//function
void sort(int numbers[], int n)
{
	int min;
	int index;
	int i;
	
	do
	{
		min = numbers[0];
		index = 0;

		for(i = 1; i < n; ++i)
			if(numbers[i] < min)
			{
				min = numbers[i];
				index = i;
			}
			
			numbers[index] = numbers[n-1];
			numbers[n-1] = min;

			--n;
	}
	while(n >= 1);
}